package 线程优先级;

// 线程优先级测试
public class TestPriority {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+"----->"+"优先级为"+Thread.currentThread().getPriority());

        MyPriority myPriority = new MyPriority();

        Thread thread = new Thread(myPriority);
        Thread thread1 = new Thread(myPriority);
        Thread thread2 = new Thread(myPriority);
        Thread thread3 = new Thread(myPriority);
        Thread thread4 = new Thread(myPriority);


        thread.setPriority(10);
        thread.start();

        thread1.setPriority(1);
        thread1.start();

        thread2.setPriority(6);
        thread2.start();

        thread3.setPriority(8);
        thread3.start();

        thread4.setPriority(2);
        thread4.start();


    }
}
 class MyPriority implements Runnable{

     @Override
     public void run() {
         System.out.println(Thread.currentThread().getName()+"----->"+"优先级为"+Thread.currentThread().getPriority());
     }
 }